package com.boot.stomp;

import com.boot.security.service.authentication.TokenService;
import com.boot.stomp.authentication.StompAuthenticationHandler;
import com.boot.stomp.interceptor.MultipleChannelInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.support.ChannelInterceptor;

@Configuration
public class SecurityStompAutoConfiguration {

    @Bean
    StompAuthenticationHandler stompAuthenticationHandler(TokenService tokenService) {
        return new TokenAuthenticationHandler(tokenService);
    }

    //    @Bean
    //    StompAuthenticationHandler authenticationHandler(UserMapper userMapper, PasswordEncoder encoder) {
    //        return new LoginAuthenticationHandler(userMapper, encoder);
    //    }

    @Bean
    ChannelInterceptor multipleChannelInterceptor(StompAuthenticationHandler[] handlers) {
        return new MultipleChannelInterceptor(handlers);
    }

}
